/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
/* vi: set expandtab shiftwidth=4 tabstop=4: */
#ifndef COM_MODP_TIMES33_H
#define COM_MODP_TIMES33_H

#include <stdint.h>
#include <string.h>

class Times33 {
public:

    const char* name() const
    {
        return "Times33";
    }

    uint32_t hash32(uint32_t a) const
    {
        uint32_t hash = 0;
        const uint8_t* key = (const uint8_t*)(&a);
        hash = hash * 33 + key[0];
        hash = hash * 33 + key[1];
        hash = hash * 33 + key[2];
        hash = hash * 33 + key[3];
        return hash;
    }

    uint32_t hashStr(const char* data, size_t len) const
    {
        uint32_t hash = 0;
        const uint8_t* key = (const uint8_t*) data;
        for (size_t i = 0; i < len; ++i) {
            hash = hash*33 + *key++;
        }
        return hash;
    }
};


#endif
